package cn.iocoder.yudao.module.book.dal.mysql.bookshelfcatalogue;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.book.controller.admin.bookshelfcatalogue.vo.BookShelfCataloguePageReqVO;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookShelfRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.bookshelfcatalogue.BookShelfCatalogueDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 绘本分类 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BookShelfCatalogueMapper extends BaseMapperX<BookShelfCatalogueDO> {

    default PageResult<BookShelfCatalogueDO> selectPage(BookShelfCataloguePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BookShelfCatalogueDO>()
            .likeIfPresent(BookShelfCatalogueDO::getCategoryName, reqVO.getCategoryName())
            .eqIfPresent(BookShelfCatalogueDO::getType, reqVO.getType())
            .betweenIfPresent(BookShelfCatalogueDO::getCreateTime, reqVO.getCreateTime())
            .orderByDesc(BookShelfCatalogueDO::getId));
    }

    List<AppBookShelfRespVO> selectBookShelfByType(@Param("type") String type, @Param("id") Long id);
}